// MainWndSubclass.h: interface for the CMainWndSubclass class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_MAINWndSUBCLASS_H__BA9A99A2_6470_11D9_9AC5_0050BAD093CF__INCLUDED_)
#define AFX_MAINWndSUBCLASS_H__BA9A99A2_6470_11D9_9AC5_0050BAD093CF__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "WndSubclass.h"
#include "MainMenuSubclass.h";

class CMainWndSubclass : public CWndSubclass  
{
public:
	CMainWndSubclass();
	virtual ~CMainWndSubclass();

public:
	virtual BOOL SubclassWindow(CWnd* pRealWnd);
	virtual BOOL UnSubclassWindow();

protected:
	virtual LRESULT WindowProc(UINT msg, WPARAM wp, LPARAM lp);

private:
	void OnNcCalcSize(BOOL bValid, LPARAM lParam);
	void OnNcPaint(HRGN hUpdateRgn);
	BOOL OnNcActivate(BOOL bActive);
	UINT OnNcHitTest(CPoint point);
	UINT OnNcLButtonDown(int x, int y);
	UINT OnNcMouseMove(int x, int y);
	UINT OnNcLButtonDblClk(int x, int y);
	void OnSize();
	void OnSetRgn();
	void OnSetText(CString strTitle);
	void OnEraseBkGnd();
	HRESULT OnCtlColor(CDC* pDC, HWND hWnd);
	UINT OnDrawItem(LPDRAWITEMSTRUCT lpDIS);
	UINT OnMeasureItem(LPMEASUREITEMSTRUCT lpMIS);

private:
	CString m_strTitle;
	DWORD m_styleOld;
	CMenu m_menuSystem;
	BOOL m_bActive;
	void RemoveGarbagePointFromRectRgn(CDC* pDC, HRGN hRgnWnd, COLORREF crColor, LPRECT lpRect);

public:
	/*Resource*/
	//Depend on the right and top edge
	BOOL m_bExit;
	BOOL m_bMax;
	BOOL m_bMin;
	BOOL m_bIcon;

public:
	static CRect m_rcIcon;
	static CRect m_rcExit; 
	static CRect m_rcMax;
	static CRect m_rcMin;
	static int m_nLeft;
	static int m_nTop;
	static int m_nRight;
	static int m_nBottom;
	static int m_nCaption;
	static COLORREF m_crBackCaption;
	static COLORREF m_crBackTopEdge;
	static COLORREF m_crBackBottomEdge;
	static COLORREF m_crBackLeftEdge;
	static COLORREF m_crBackRightEdge;

	static COLORREF m_crClientBack;

	/*Caption Bitmap Handle*/
	static HBITMAP m_hMemLeftCaption;
	static HBITMAP m_hMemMiddleCaption;
	static HBITMAP m_hMemRightCaption;
	static HBITMAP m_hMemExitCaption;
	static HBITMAP m_hMemMaxCaption;
	static HBITMAP m_hMemMinCaption;

	/*Top Edge Bitmap Handle*/
	static HBITMAP m_hMemLeftTopEdge;
	static HBITMAP m_hMemMiddleTopEdge;
	static HBITMAP m_hMemRightTopEdge;

	/*Bottom Edge Bitmap Handle*/
	static HBITMAP m_hMemLeftBottomEdge;
	static HBITMAP m_hMemMiddleBottomEdge;
	static HBITMAP m_hMemRightBottomEdge;

	/*Bottom Edge Bitmap Handle*/
	static HBITMAP m_hMemTopLeftEdge;
	static HBITMAP m_hMemMiddleLeftEdge;
	static HBITMAP m_hMemBottomLeftEdge;

	/*Bottom Edge Bitmap Handle*/
	static HBITMAP m_hMemTopRightEdge;
	static HBITMAP m_hMemMiddleRightEdge;
	static HBITMAP m_hMemBottomRightEdge;

protected:
	void PaintMainWnd(CDC& dcWin);
	/*declare these functions virtual ones to order to change them in derived class*/
	virtual void OnDrawCaption(CDC* pDC, LPSIZE lpSize, BOOL bActive);
	virtual void OnDrawLeftEdge(CDC* pDC, LPSIZE lpSize, BOOL bActive);
	virtual void OnDrawRightEdge(CDC* pDC, LPSIZE lpSize, BOOL bActive);
	virtual void OnDrawTopEdge(CDC* pDC, LPSIZE lpSize, BOOL bActive);
	virtual void OnDrawBottomEdge(CDC* pDC, LPSIZE lpSize, BOOL bActive);
	virtual void OnSetCustomRgn(CDC* pDC, HRGN hRgnWnd);

private: //Menu
	CMainMenuSubclass m_mainMenuSubclass;
};

#endif // !defined(AFX_MAINWndSubclass_H__BA9A99A2_6470_11D9_9AC5_0050BAD093CF__INCLUDED_)
